package 剑指offer.调整数组顺序使奇数位于偶数前面_13;

import java.util.Arrays;

public class Main {
	public static void main(String[] args){
		int[] n = new int[]{1,2,3,4,5,6,7};
		reOrderArray(n);
	}
    public static void reOrderArray(int [] array) {
        int[] odd = new int[array.length];
        int j = 0;
        int[] even = new int[array.length];
        int k = 0;
        for(int i = 0; i < array.length; i++){
        	if((array[i] & 1) == 1){
        		odd[j] = array[i];
        		j++;
        	}else{
        		even[k] = array[i];
        		k++;
        	}
        }
        for(int i = 0; i < k; i++){
        	odd[j] = even[i];
        	j++;
        }
        for(int i = 0; i < odd.length; i++){
        	array[i] = odd[i];
        }
    }
}
